package com.kingdee.eas.custom.hr.attendance.app;

import java.util.Date;

import org.apache.log4j.Logger;

import com.kingdee.bos.BOSException;
import com.kingdee.bos.Context;
import com.kingdee.eas.util.app.DbUtil;
import com.kingdee.jdbc.rowset.IRowSet;

public class SpecialOperationMgrEntryControllerBean extends
		AbstractSpecialOperationMgrEntryControllerBean {
	private static Logger logger = Logger
			.getLogger("com.kingdee.eas.custom.hr.attendance.app.SpecialOperationMgrEntryControllerBean");

	@Override
	public IRowSet getSpecialOperationMgrByPerson(Context ctx, String person,
			Date date) throws BOSException {
		StringBuffer buffer = new StringBuffer();
		buffer
				.append("SELECT DISTINCT C.FID AS ID,C.FNUMBER AS FNUMBER,C.FNAME_L2 AS FNAME,C.CFHALFDAY AS CFHALFDAY FROM CT_KQ_SPECIALOPERATIONMGRENTRY A ");
		buffer
				.append("LEFT JOIN CT_KQ_SPECIALOPERATIONMGR B ON A.FBILLID=B.FID ");
		buffer
				.append("INNER JOIN CT_BAS_SPECIALWORKCODE C ON A.CFSPECIALCODEID=C.FID");
		buffer
				.append(" WHERE B.FBILLSTATE=3 AND TO_CHAR(A.CFSTARTDATE,'yyyy-MM-dd')<=TO_CHAR(?,'yyyy-MM-dd')");
		buffer
				.append(" AND (TO_CHAR(A.CFENDDATE,'yyyy-MM-dd')>=TO_CHAR(?,'yyyy-MM-dd')");
		buffer.append(" OR A.CFENDDATE IS NULL)");
		buffer.append(" AND A.CFPERSONID=?");

		Object[] params = new Object[] { new java.sql.Date(date.getTime()),
				new java.sql.Date(date.getTime()), person };
		IRowSet rs = DbUtil.executeQuery(ctx, buffer.toString(), params);
		return rs;
	}
}